package com.zyw.module.console.sys.controller;

import com.zyw.module.console.sys.po.Menu;
import com.zyw.module.console.sys.service.MenuService;
import com.zyw.mvc.servlet.BaseController;
import com.zyw.mvc.support.WrappedResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("${path.console.prefix}/menu")
public class MenuController extends BaseController {
    @Autowired
    private MenuService menuService;

    @RequestMapping("get")
    @ResponseBody
    public WrappedResult get(Integer id) {
        return wrappedSuccessResult(menuService.get(id));
    }

    @RequestMapping("save")
    @ResponseBody
    public WrappedResult save(Menu menu) {
        int i = menuService.insert(menu);
        if (i > 0) {
            return wrappedSuccessResult(null);
        } else {
            return wrappedFaliedResult("保存失败");
        }
    }
}